package cn.IT.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Reply entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "reply", catalog = "itsupport")
public class Reply implements java.io.Serializable {

	// Fields

	private Integer replyId;
	private Topic topic;
	private User user;
	private String replyContent;
	private Integer likeCount;
	private Integer isReaded;
	private Date createdOn;
	private Set<Like> likes = new HashSet<Like>(0);

	// Constructors

	/** default constructor */
	public Reply() {
	}

	/** full constructor */
	public Reply(Topic topic, User user, String replyContent,
			Integer likeCount, Integer isReaded,
			Date createdOn) {
		this.topic = topic;
		this.user = user;
		this.replyContent = replyContent;
		this.likeCount = likeCount;
		this.isReaded = isReaded;
		this.createdOn = createdOn;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "replyId", unique = true, nullable = false)
	public Integer getReplyId() {
		return this.replyId;
	}

	public void setReplyId(Integer replyId) {
		this.replyId = replyId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "topicId", nullable = false)
	public Topic getTopic() {
		return this.topic;
	}

	public void setTopic(Topic topic) {
		this.topic = topic;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "userId", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "replyContent", nullable = false, length = 65535)
	public String getReplyContent() {
		return this.replyContent;
	}

	public void setReplyContent(String replyContent) {
		this.replyContent = replyContent;
	}

	@Column(name = "likeCount", nullable = false)
	public Integer getLikeCount() {
		return this.likeCount;
	}

	public void setLikeCount(Integer likeCount) {
		this.likeCount = likeCount;
	}

	@Column(name = "isReaded", nullable = false)
	public Integer getIsReaded() {
		return this.isReaded;
	}

	public void setIsReaded(Integer isReaded) {
		this.isReaded = isReaded;
	}

	@Column(name = "createdOn", nullable = false, length = 19)
	public Date getCreatedOn() {
		return this.createdOn;
	}

	public void setCreatedOn(Date createdOn) {
		this.createdOn = createdOn;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "reply")
	public Set<Like> getLikes() {
		return this.likes;
	}

	public void setLikes(Set<Like> likes) {
		this.likes = likes;
	}

}